package net.roobook.cms.modules.demo.service.impl;

import net.roobook.cms.modules.demo.dao.DemoMapper;
import net.roobook.cms.modules.demo.entity.DemoEntity;
import net.roobook.cms.modules.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionException;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Roobook
 * @email 327878610@qq.com
 * @link https://roobook.net
 * @Description Demo测试Service实现层
 * @date 2023/9/7 17:11
 **/
@Service
@Transactional(rollbackFor = Exception.class)
public class DemoServiceImpl implements DemoService {
    @Autowired
    private DemoMapper demoMapper;

    @Override
    public int add(DemoEntity demo) throws TransactionException {
        return demoMapper.insert(demo);
    }

    @Override
    public int delete(DemoEntity demo) throws TransactionException {
        return demoMapper.delete(demo);
    }

    @Override
    public int update(DemoEntity demo) throws TransactionException {
        return demoMapper.updateByPrimaryKey(demo);
    }

    @Override
    public List<DemoEntity> queryDemoEntity(DemoEntity demo) {
        return demoMapper.select(demo);
    }

    @Override
    public DemoEntity queryDemoById(Integer id) {
        return demoMapper.selectByPrimaryKey(id);
    }
}
